package com.orange.score.app;

import android.app.Activity;
import android.app.Application;
import com.orange.score.activity.entry.MainActivity;
import com.orange.score.activity.entry.RealtimeMatchActivity;
import com.orange.score.model.league.LeagueManager;
import com.orange.score.model.match.FollowMatchManager;
import com.orange.score.model.repository.RepositoryManager;
import com.orange.score.service.IndexService;
import com.orange.score.service.MatchService;
import com.orange.score.service.RepositoryService;

public class ScoreApplication extends Application
{
  public static boolean alive;
  public static Activity currentActivity = null;
  static boolean detectAppUpdate;
  public static FollowMatchManager followMatchManager;
  public static IndexService indexService;
  public static boolean isBackground;
  public static MainActivity mainActivity;
  public static RealtimeMatchActivity realtimeMatchActivity;
  public static MatchService realtimeMatchService = new MatchService();
  public static RepositoryService repositoryService = new RepositoryService();

  static
  {
    indexService = new IndexService();
    mainActivity = null;
    realtimeMatchActivity = null;
    alive = false;
    isBackground = false;
    followMatchManager = null;
    detectAppUpdate = false;
  }

  public static MainActivity getMainActivity()
  {
    return mainActivity;
  }

  public static void gotoRealtimeMatchTab(boolean paramBoolean)
  {
    if (mainActivity != null)
    {
      if (realtimeMatchActivity != null)
        realtimeMatchActivity.forceRefreshWhenResume = paramBoolean;
      mainActivity.selectTab("realtime_match");
    }
  }

  public static boolean hasDetectUpdate()
  {
    return detectAppUpdate;
  }

  public static boolean isAlive()
  {
    return alive;
  }

  public static boolean isBackground()
  {
    return isBackground;
  }

  public static void reloadRealtimMatch()
  {
    if (realtimeMatchActivity != null)
      realtimeMatchActivity.refreshCurrentMatchList();
  }

  public static void setAlive()
  {
    alive = true;
  }

  public static void setBackground(boolean paramBoolean)
  {
    isBackground = paramBoolean;
  }

  public static void setDetectUpdate()
  {
    detectAppUpdate = true;
  }

  public static void setMainActivity(MainActivity paramMainActivity)
  {
    mainActivity = paramMainActivity;
  }

  public static void setRealtimeMatchActivity(RealtimeMatchActivity paramRealtimeMatchActivity)
  {
    realtimeMatchActivity = paramRealtimeMatchActivity;
  }

  public IndexService getIndexService()
  {
    return indexService;
  }

  public LeagueManager getLeagueManager(int paramInt)
  {
    LeagueManager localLeagueManager;
    if (paramInt == 1)
      localLeagueManager = getRealtimeMatchService().getLeagueManager();
    while (true)
    {
      while (true)
      {
        return localLeagueManager;
        if (paramInt != 2)
          break;
        localLeagueManager = getIndexService().getLeagueManager();
      }
      localLeagueManager = null;
    }
  }

  public RealtimeMatchActivity getRealtimeMatchActivity()
  {
    return realtimeMatchActivity;
  }

  public MatchService getRealtimeMatchService()
  {
    return realtimeMatchService;
  }

  public RepositoryManager getRepositoryManager()
  {
    return repositoryService.getRepositoryManager();
  }

  public RepositoryService getRepositoryService()
  {
    return repositoryService;
  }

  public void setRealtimeMatchService(MatchService paramMatchService)
  {
    realtimeMatchService = paramMatchService;
  }

  public void setRepositoryService(RepositoryService paramRepositoryService)
  {
    repositoryService = paramRepositoryService;
  }
}